<#include "/common/head.html"/> 
<table id="dg"></table>
<div id="tb" style="padding:2px 5px;">
  	<div style="text-align: left; margin:6px;">
  	
       <!-- <div id="searchBtnWrap" style="float:right; padding-right:40px;">
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="glyphicon-search" onclick="zcurdSearch(this)">搜索</a>
        </div> -->
        
        <div id="searchBtnWrap" style="float:right; padding-right:40px;">           
        	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="glyphicon-search"  onclick="zcurdSearch(this)">搜索</a> 
        </div> 
        
        <div class="wrap_search">
      		<span class="search_item">
            	<span class="item_text">规则名称 : </span>
            	<span class="item_obj">
            		<input class="easyui-textbox" name="name" id="name" style="width:100px"/>
            	</span>    
            </span>
        </div>
     </div>
     
     <a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-plus" plain="true" onclick="add()">添加规则</a>
     <a href="javascript:void(0)" class="easyui-linkbutton updateBtn" iconCls="glyphicon-pencil" plain="true" onclick="update()">编辑</a>
     <a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-remove" plain="true" onclick="searchback()">搜索返回</a>
     <a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-remove" plain="true" onclick="delete1()">删除</a>
</div>
<script type="text/javascript">
//查询回显
var datagrid = $("#dg");
var dgOptions = {
        rownumbers:true,
    	fit:true,
    	border:false,
    	striped:true,
        rownumbers:true,
    	url:'listData',
    	method:'post',
    	toolbar:'#tb',
    	pageSize: 20,
    	pagination:true,
    	multiSort:true,
    	singleSelect:true,
        queryParams: getInitParam(),
        columns: [[
				  {field:'ruleCode', title:'规则编号', width:100}
	           	 ,{field:'name', title: '规则名称', width:100}
		         ,{field:'description',title: '规则描述', width:200}
	           	 ,{field:'section', title: '规则区间/条件', width:80}
	           	 ,{field:'createTime', title: '创建时间', width:116}
	           	 ,{field:'updateTime', title: '更新时间', width:116}
	           ]]
	};
$(function() {
	datagrid.datagrid(dgOptions);
});

//添加
function add() {
	location.replace('add');
}
function update() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	var id = rowsSel[0].id;
	location.replace('update?id='+id);
}

//删除
function delete1() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	var id= rowsSel[0].id;
	confirmMsg("确认删除吗？", function() {
	/* 	var bb="";
		for (var i = 0; i < rowsSel.length; i++) {
			var aa = rowsSel[i].positionid;
			bb = aa + "|" +bb;
		} */
		var id = rowsSel[0].id;
		$.post("delete", {id: id}, function(data) {
			var result = data.result;
			if(result=='success'){
				showMsg("删除成功！");
				datagrid.datagrid("reload");
			}else{
				showWarnMsg(result);
        		return;
			}
		});
	});
}

//搜索
function zcurdSearch() {
	var param={
			name:$("#name").val(),
		}
	datagrid.datagrid("load", param);
}

function getInitParam() {
	 var param = {
		/* 	 goodsname:$("#goodsname").combobox("getText"); */
	 };
	/* $("#tb :input[name]").each(function(i, item) {
		if($(item).val()) {
			param["queryParams[" + $(item).attr("name") + "]"] = $(item).val().trim();	
		}
	});  */
	return param;
}
//搜索返回
function searchback() {
	location.replace("list");
}
</script>
<#include "/common/dialogWindow.html"/>
<#include "/common/foot.html"/>